// 缓存服务
export default class Cache {
  // 缓存名称
  private _name: string;
  // 容器
  private _map: Map<any, any> = new Map();

  constructor(name: string) {
    this._name = name;
  }

  public set(key: any, val: any): any {
    let { _map } = this;
    _map.set(key, val);
    return _map.get(key);
  }

  public get(key: any): any {
    return this._map.get(key) || null;
  }

  public static createCache(name: string) {
    return new Cache(name);
  }
}
